package efg.tasks;

import interfacesFerrovia.ControleFerrovia;

public abstract class SchedulableTask implements Comparable<SchedulableTask> {
	
	private Integer scheduledTime;
	
	public SchedulableTask(Integer scheduledTime) {
		assert(scheduledTime != null);
		assert(scheduledTime > 0);
		this.scheduledTime = scheduledTime;
	}
	
	public abstract void execute(ControleFerrovia railwayControl);

	public Integer getScheduledTime() {
		assert(scheduledTime != null);
		assert(scheduledTime > 0);
		return scheduledTime;
	}
	
	public void delay(Integer time) {
		assert(scheduledTime != null);
		assert(scheduledTime > 0);
		assert(time != null);
		assert(time > 0);
		this.scheduledTime += time;
	}

	@Override
	public int compareTo(SchedulableTask o) {
		assert(scheduledTime != null);
		assert(scheduledTime > 0);
		assert(o.getScheduledTime() != null);
		assert(o.getScheduledTime() > 0);
		return scheduledTime.compareTo(o.getScheduledTime());
	}

}
